<template>
    <!-- 组件的模板 -->
    <div class="page resume" v-if="center"> 
        <template v-if="vcs.personal_info.mobile || vcs.personal_info.gender || vcs.personal_info.height || vcs.personal_info.weight || vcs.personal_info.age || vcs.personal_info.idnumber || vcs.personal_info.province_str || vcs.personal_info.datail_address">
            <div class="weui-cells__title">基本信息</div>
            <div class="weui-cells">
                <div class="weui-cell" v-if="vcs.personal_info.name">
                    <div class="weui-cell__bd">
                        <p><span class="title">姓名</span>{{vcs.personal_info.name}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.personal_info.idnumber">
                    <div class="weui-cell__bd">
                        <p><span class="title">身份证号</span>{{formatIdCard}} <a style="color: #999999;font-size: 14px;margin-left: 12px;" href="javascript:;" @click="checkIdCard(vcs.personal_info.idnumber)">查看</a></p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.personal_info.mobile">
                    <div class="weui-cell__bd">
                        <p><span class="title">电话</span>{{vcs.personal_info.mobile}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.personal_info.gender">
                    <div class="weui-cell__bd">
                        <p><span class="title">性别</span>{{vcs.personal_info.gender}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.personal_info.height">
                    <div class="weui-cell__bd">
                        <p><span class="title">身高</span>{{vcs.personal_info.height}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.personal_info.weight">
                    <div class="weui-cell__bd">
                        <p><span class="title">体重</span>{{vcs.personal_info.weight}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.personal_info.age">
                    <div class="weui-cell__bd">
                        <p><span class="title">年龄</span>{{vcs.personal_info.age}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.personal_info.province_str">
                    <div class="weui-cell__bd">
                        <p v-if="vcs.personal_info.province_str == vcs.personal_info.city_str"><span class="title">居住地点</span>{{vcs.personal_info.province_str}}{{vcs.personal_info.district_str}}</p>
                        <p v-else><span class="title">居住地点</span>{{vcs.personal_info.province_str}}{{vcs.personal_info.city_str}}{{vcs.personal_info.district_str}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.personal_info.datail_address">
                    <div class="weui-cell__bd">
                        <p><span class="title">详细地址</span>{{vcs.personal_info.datail_address}}</p>
                    </div>                
                </div>       
            </div>
        </template>       
        <div v-if="vcs.education_backgroud.degree || vcs.education_backgroud.school_name || vcs.education_backgroud.specialty || (vcs.education_backgroud.graduate_date  && vcs.education_backgroud.graduate_date != 0)">
            <div class="weui-cells__title">教育经历</div>
            <div class="weui-cells">
                <div class="weui-cell" v-if="vcs.education_backgroud.degree">
                    <div class="weui-cell__bd">
                        <p><span class="title">学历</span>{{vcs.education_backgroud.degree}}</p>
                    </div>                
                </div>                
                <div class="weui-cell" v-if="vcs.education_backgroud.school_name">
                    <div class="weui-cell__bd">
                        <p><span class="title">学校</span>{{vcs.education_backgroud.school_name}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.education_backgroud.specialty">
                    <div class="weui-cell__bd">
                        <p><span class="title">专业</span>{{vcs.education_backgroud.specialty}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.education_backgroud.graduate_date  && vcs.education_backgroud.graduate_date != 0">
                    <div class="weui-cell__bd">
                        <p><span class="title">毕业时间</span>{{vcs.education_backgroud.graduate_date}}</p>
                    </div>                
                </div>                
            </div>
        </div>
        <div v-if="vcs.bank_info.bank || vcs.bank_info.bank_info || (vcs.bank_info.bank_card_number && vcs.bank_info.bank_card_number != 0)">
            <div class="weui-cells__title">银行信息</div>
            <div class="weui-cells">
                <div class="weui-cell" v-if="vcs.bank_info.bank">
                    <div class="weui-cell__bd">
                        <p><span class="title">开户人</span>{{vcs.bank_info.bank}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.bank_info.bank_info">
                    <div class="weui-cell__bd">
                        <p><span class="title">开户行</span>{{vcs.bank_info.bank_info}}</p>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.bank_info.bank_card_number && vcs.bank_info.bank_card_number != 0">
                    <div class="weui-cell__bd">
                        <p><span class="title">银行卡号</span>{{vcs.bank_info.bank_card_number}}</p>
                    </div>                
                </div>
            </div>
        </div>
        <div>
            <div class="weui-cells__title">其他</div>
            <div class="weui-cells">
                <div class="weui-cell" v-if="vcs.other.entry_date && vcs.other.entry_date != 0" >
                    <div class="weui-cell__bd">
                        <div class="gride-item">
                            <div class="title label">入职日期</div>
                            <div class="text">{{vcs.other.entry_date}}</div>
                        </div>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.other.personnel_number">
                    <div class="weui-cell__bd">
                        <div class="gride-item">
                            <div class="title label">人员编号</div>
                            <div class="text">{{vcs.other.personnel_number}}</div>
                        </div>
                    </div>                
                </div>
                <div class="weui-cell" v-if="vcs.other.emergency_contact_person">
                    <div class="weui-cell__bd">
                        <div class="gride-item">
                            <div class="title label">紧急联系人</div>
                            <div class="text">{{vcs.other.emergency_contact_person}}</div>
                        </div>
                    </div>             
                </div>
                <div class="weui-cell" v-if="vcs.other.emergency_contact_person_mobile">
                    <div class="weui-cell__bd">
                        <div class="gride-item">
                            <div class="title label">紧急联系人手机号</div>
                            <div class="text">{{vcs.other.emergency_contact_person_mobile}}</div>
                        </div>
                    </div>             
                </div>
                <div class="weui-cell" v-if="vcs.other.contact_person_relation_txt">
                    <div class="weui-cell__bd">
                        <div class="gride-item">
                            <div class="title label">紧急联系人关系</div>
                            <div class="text">{{vcs.other.contact_person_relation_txt}}</div>
                        </div>
                    </div>             
                </div>
                <div class="weui-cell" v-if="vcs.other.card_front">
                    <div class="weui-cell__bd">
                        <div class="gride-item">
                            <div class="title label">身份证正面</div>
                            <div class="text"><img class="img_self" :src="vcs.other.card_front" alt="" @click="previewPic(vcs.other.card_front)"></div>
                        </div>
                    </div>             
                </div>
                <div class="weui-cell" v-if="vcs.other.card_back">
                    <div class="weui-cell__bd">
                        <div class="gride-item">
                            <div class="title label">身份证反面</div>
                            <div class="text"><img class="img_self" :src="vcs.other.card_back" alt="" @click="previewPic(vcs.other.card_back)"></div>
                        </div>
                    </div>             
                </div>
            </div>
        </div>
        <div v-if="vcs.other.form_list && vcs.other.form_list.length">
            <div class="weui-cells__title">自定义信息</div>
            <div class="weui-cells">
                <template v-for="item in vcs.other.form_list" :key="item.id">
                    <!-- <div class="weui-cell" v-if="(item.type === 'SingleText' && item.info.value) || (item.type === 'Imageview' && item.info.value.length)"> -->
                    <div class="weui-cell">
                        <!-- <template> -->
                            <div class="weui-cell__bd" v-if="item.type === 'SingleText'">
                                <div class="weui-cell__bd">
                                    <div class="gride-item">
                                        <div class="title label">{{item.info.title}}</div>
                                        <div class="text">{{item.info.value}}</div>
                                    </div>
                                </div>
                            </div> 
                            <div class="weui-cell__bd" v-if="item.type === 'Imageview'">
                                <div class="gride-item">
                                    <div class="title label">{{item.info.title}}</div>
                                    <div class="text"><img v-for="v in item.info.value" class="img_self" :src="v" alt="" @click="previewPic(v)"></div>
                                </div>
                            </div> 
                        <!-- </template> -->
                    </div>
                </template>
            </div>
        </div>
    </div>  

    <div class="page" v-if="empty">
        <div class="mod-empty">
            <div class="icon icon_1"></div>
            <p class="tip">该成员暂无简历信息</p>
        </div>
    </div> 
        
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import clientUi from 'gapi/clientUi.js'
    import widget from 'gapi/widget.js'
    import * as util from 'js/util.js'
    import commonPage from 'clientApi/commonPage.js'

    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

     let userid = ''
     let doumi_user_id = ''
    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
                empty: false,
                center: false,
                vcs:{
                    personal_info: {},
                    education_backgroud: {},
                    work_experience: [],
                    third_party_accout: {},
                    bank_info: {},
                    other: {}
                },
                formatIdCard:'',
                logo_url_big: '',  //查看大图
                logo_thumb_url: '',   // 原图 小图
                teamId: 0,
                projectId: 0,
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        computed: {
            // 将身份证后八位用* 代替
            id_card_num: function () {
                return this.vcs.personal_info.id_card_num.replace(/(\w{4})\w{4}(\w{4})/, '$1****$2')
            }

        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
                userid = util.getUrddataString('userId')
                doumi_user_id =util.getUrddataString('doumiUserId')
                this.teamId = util.getUrddataString('tid')
                this.projectId = util.getUrddataString('pid')
                this.vcInit()

            },
            vcInit (){
                commonPage.loadPageStatus('loading')
                util.ajax({
                    url:'/user/profile',
                    type:'GET',
                    data:{
                        team_id:this.teamId,
                        project_id:this.projectId,
                        user_id:userid,
                        doumi_user_id:doumi_user_id
                    },
                    timeout:10000,
                    success:(obj) => {
                        console.log(JSON.stringify(obj.data))
                        commonPage.loadPageStatus('loadSuccess')
                        if(obj&&obj.errno == 0){
                            // this.empty = false
                            if(obj.data != ''){
                                this.empty = false
                                this.center = true
                                this.logo_url_big = obj.data.personal_info.logo_url
                                this.logo_thumb_url = obj.data.personal_info.logo_thumb_url
                                this.vcs.personal_info = obj.data.personal_info;   //个人信息
                                this.formatIdCard = obj.data.personal_info.idnumber.slice(0, -8) + '*'.repeat(8)
                                this.vcs.education_backgroud = obj.data.education_backgroud;  //教育经历
                                if(this.vcs.education_backgroud.graduate_date){
                                    this.vcs.education_backgroud.graduate_date = obj.data.education_backgroud.graduate_date.replace(/-/g,'年') + '月'
                                }
                                this.vcs.work_experience = obj.data.work_experience;  //工作经历
                                this.vcs.third_party_accout = obj.data.third_party_accout;  //联系方式
                                this.vcs.bank_info = obj.data.bank_info;  //银行信息
                                this.vcs.other = obj.data.other;  //其它信息
                                if(this.vcs.other.entry_date){
                                    this.vcs.other.entry_date = obj.data.other.entry_date
                                    this.vcs.other.entry_date = this.vcs.other.entry_date.replace(/-/,'年')
                                    this.vcs.other.entry_date = this.vcs.other.entry_date.replace(/-/,'月') + '日'
                                }
                            }else{
                                this.empty = true
                                this.center = false
                            }
                        }else{
                             widget.toast(obj.errmsg)
                        }
                    },
                    error: (xhr, status) => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('服务器异常')
                    },
                    noNetwork: () => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
            checkIdCard(idCard){
                this.formatIdCard = idCard 
            },
            /**
             * 头像大图预览
             */
            bigPicture (){
                let that = this;
                let title = '个人头像';
                let imgArr = [];
                let subUrl = this.logo_url_big;
                imgArr.push(subUrl); 
                let index = imgArr.length-1;
                clientUi.bigPicturePreview(title, imgArr, index)
            },
            previewPic(url){
                clientUi.bigPicturePreview('预览', [url], 0)
            },
            /*拨打电话*/
            call (mobile){
                const title = '拨打电话';
                const message = mobile;
                const okBtn = '确定';
                const cancelBtn = '取消';
                const imageName = 'meiyou';
                clientUi.showPhoneDialog(title, message, okBtn, cancelBtn, imageName, () => {
                    
                })
            }
        },
        created(){

            this.init();
        }
        
    }

    
</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/talent-pool.css"></style>
<style>
.gride-item{
    display: flex;
    align-items: center
}
.gride-item .label{
    width: 60px;

};
.gride-item .text{
    flex: auto;
};
</style>



